<#import "../macro/components.ftl" as components/>
<#include "../macro/layout_default.ftl"/>

<@head>
<link rel="stylesheet" href="/misc/adminlte-2.3.7/plugins/daterangepicker/daterangepicker.css"/>
</@head>

<@body>
<#--<script src="/misc/adminlte-2.3.7/plugins/daterangepicker/moment.min.js"></script>-->
<#--<script src="/misc/adminlte-2.3.7/plugins/daterangepicker/daterangepicker.js"></script>-->
<script src="/misc/app/js/salesman_payrule_list.js"></script>
<script src="/misc/jquery-fileupload-9.14.0/jquery.ui.widget.js"></script>
<script src="/misc/jquery-fileupload-9.14.0/jquery.fileupload.js"></script>
<script>var PicDomain = "${PicDomain!}"</script>
</@body>

<@layout_default>
<div class="box">
    <div class="box-header with-border">
        <span class="pull-right text-muted">共 ${pagelist.resultTotal} 条记录</span>
        <input type="hidden" id="resultTotal_hidden" value="${pagelist.resultTotal}" />
        <form class="form-inline" action="/salemanPayrule/list">
            <div class="input-group">
                <div class="input-group-addon">规则名称</div>
                <input type="text" class="form-control" style="width: 260px" name="name" value="${name!}" placeholder="规则名称"/>
            </div>
            <div class="input-group">
                <div class="input-group-addon">状态</div>
                <select class="form-control" name="state">
                    <option value="">全部</option>
                    <option value="0" ${(state?exists && state == 0)?string("selected","")}>未启用</option>
                    <option value="1" ${(state?exists && state == 1)?string("selected","")}>使用中</option>
                    <option value="2" ${(state?exists && state == 2)?string("selected","")}>已失效</option>
                    <option value="3" ${(state?exists && state == 3)?string("selected","")}>已停用</option>
                </select>
            </div>

            <button type="submit" class="btn btn-warning"><i class="fa fa-search"></i> 查询</button>
            <button type="button" class="btn btn-default" name="btn_new_payrule" id="btn_new_payrule"><i class="fa fa-plus"></i> 创建规则</button>
        </form>
        <form class="form-inline hide">
            <input class="form-control"/>
            <input type="email" class="form-control"/>
            <button type="submit" class="btn btn-default">Send invitation</button>
        </form>
    </div>

    <!-- /.box-header -->
    <div class="box-body">
        <table class="table table-striped table-hover">
            <tr>
                <th>ID</th>
                <th>规则名称</th>
                <th>时间</th>
                <th>当前状态</th>
                <th>创建时间</th>
                <th>创建人</th>
                <th>操作</th>
            </tr>

            <#if (pagelist.result?size > 0)>

                <#list pagelist.result as item>
                    <tr>
                        <td>${item.id?c}</td>
                        <td>${item.name!}</td>
                        <td><#if item.valid_begin_time?exists>${item.valid_begin_time?number_to_date}至${item.valid_end_time?number_to_date}</#if></td>

                        <td><#if item.state == 0><span class="text-red">未启用</span>
                        <#elseif item.state == 1><span class="text-green">使用中</span>
                        <#elseif item.state == 2><span class="text-yellow">已失效</span>
                        <#else><span class="text-yellow">已停用</span>
                        </#if>
                        </td>
                        <td>${item.c_time?number_to_date?string("yyyy-MM-dd HH:mm:ss")}</td>
                        <td>${item.account!}</td>
                        <td>
                            <button type="button" class="btn btn-default btn-xs btn_payrule_detail" name="btn_payrule_detail"  data-payrule-id="${item.id?c}">查看</button>

                            <#if item.state==0>
                                <button type="button" class="btn btn-default btn-xs btn_edit_payrule" name="btn_edit_payrule" data-payrule-id="${item.id?c}">编辑</button>
                                <button type="button" class="btn btn-default btn-xs btn_using_payrule"  data-activity-sta="${item.state}" data-payrule-id="${item.id?c}">启用</button>
                            </#if>
                            <#if item.state == 1>
                                <button type="button" class="btn btn-default btn-xs btn_stop_payrule"  data-activity-sta="${item.state}"  data-payrule-id="${item.id?c}">停用</button>
                            </#if>


                        </td>
                    </tr>
                </#list>
            <#else>
                <tr>
                    <td class="text-center text-muted" colspan="6"><i class="fa fa-info-circle"></i> 没有记录</td>
                </tr>
            </#if>


        </table>
        <table class="table table-striped table-hover">
            <tr>
                <td colspan="13" style="text-align:right;background-color:white;">
                    <a href="javascript:void(0);" name="btn_export"><i class="glyphicon glyphicon-save"></i> 数据导出</a>
                </td>
            </tr>
        </table>
    </div>
    <!-- /.box-body -->
    <div class="box-footer text-center">
        <@components.pagination "/salemanPayrule/list?name=${name!}&state=${state!}&page=$page",pagelist.page,pagelist.pageTotal/>
    </div>
</div>


</@layout_default>